import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<BottomNavbarState> buildReducer() {
  return asReducer(
    <Object, Reducer<BottomNavbarState>>{
      BottomNavbarAction.active: _active,
    },
  );
}

BottomNavbarState _active(BottomNavbarState state, Action action) {
  final BottomNavbarState newState = state.clone();
  final int activeIndex = action.payload ?? 0;

  newState.activeIndex = activeIndex;

  return newState;
}
